Skip to content

feat(auth): challenge-response verification on every connection attempt#3

Open
genspark-ai-developer[bot] wants to merge 1 commit intomainfrom
genspark_ai_developer
Open

feat(auth): challenge-response verification on every connection attempt#3
genspark-ai-developer[bot] wants to merge 1 commit intomainfrom
genspark_ai_developer

Conversation

@genspark-ai-developer
Copy link
Copy Markdown

Summary

Implements the requirement: before letting a user in, perform a full challenge-response round-trip to confirm the credentials actually work. If verification fails, show a clear error and block access.


Changes

server/routes/auth.ts — bug fix

  • Ordering bug fixed: the challenge row was being deleted from the DB before the expiry was checked. If a challenge was expired it was already gone when the expiry branch tried to report it.
  • Now: check expiry first, then delete.
  • Returns a distinct challenge_expired error code so the client can distinguish "wrong credentials" from "took too long".

src/services/api.js — hardened fetch layer

  • All requests now go through a single apiFetch() wrapper that:
    • catches network-level failures (fetch() throwing) and surfaces them as "Cannot reach server. Check that it is running."
    • always parses non-2xx bodies and throws their error field.
  • New verifyConnection(number, privateSigningKeyJwk) helper — performs the complete challenge → sign → verify sequence in one call. Used by all three entry-point screens.

src/pages/Setup.jsx — verification after activation

  • After the server accepts the activation code and registers the public keys, verifyConnection() is immediately called to confirm the keys work.
  • Only if verification succeeds is the vault written to local storage and the user admitted.
  • If verification fails the user sees a human-readable error (not a raw HTTP status).
  • Step-by-step status labels: Generating keys… → Activating number… → Verifying connection… → Saving vault…
  • Same verification step added to the import-from-file flow.

src/pages/Unlock.jsx — verification on password unlock

  • Uses verifyConnection() after the vault is decrypted.
  • Distinct error messages for: wrong password / server rejected credentials / server unreachable.
  • Granular status labels while each step runs.

src/pages/Entry.jsx — verification on silent auto-unlock

  • Silent mode now calls verifyConnection() before navigating to /.
  • Loading screen shows the current step name.
  • Error screen distinguishes connection errors (server down) from vault errors (corrupted keys) and includes a working Retry button that re-runs the whole check cycle.

- server/routes/auth.ts: fix ordering bug — check challenge expiry
  BEFORE deleting it from the DB; return distinct 'challenge_expired'
  error code so clients can give a clear message
- src/services/api.js: centralise all fetch calls in apiFetch() which
  surfaces network errors clearly; add verifyConnection() helper that
  runs the full challenge→sign→verify round-trip in one call
- src/pages/Setup.jsx: after activation, immediately run
  verifyConnection() to confirm the server accepted the keys before
  saving the vault; show per-step status ('Generating keys…',
  'Activating…', 'Verifying…'); show human-readable errors on failure;
  same verification step added to the import-from-file flow
- src/pages/Unlock.jsx: use verifyConnection() directly; add granular
  status labels for each step; distinguish 'wrong password' from
  'server rejected credentials' from 'server unreachable'
- src/pages/Entry.jsx: silent-mode auto-unlock now runs
  verifyConnection() and shows step-level progress; error screen
  differentiates connection errors from vault errors, and the Retry
  button properly re-runs the whole check cycle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant